<?php
/*
 * Author:  Somnath Shinde- soma.shinde@gmail.com Mobile No:- 9423792564
 * 
 * Create Date: 
 * 
 * Version of MYSQL_to_PHP: 1.1
 * 
 * Ranzani( YZ'S );
 * 
 */
//require_once 'classes/DataBaseMysql.class.php';

Class BaseDoctors {

	protected $m_intId;
	protected $m_intDepartmentId;
	protected $m_intSpecilizationId;
	protected $m_strFirstName;
	protected $m_strMiddleName;
	protected $m_strLastName;
	protected $m_strMobileNumber;
	protected $m_strPhoneNumber;
	protected $m_strOfficeNumber;
	protected $m_strSpecilizationDetails;
	protected $m_strListOfDgress;
	protected $m_intIsVisitor;
	protected $m_strVisitHospitalName;
	protected $m_strVisitDayName;
	protected $m_intVisitingCharges;
	protected $m_intWardId;
	protected $m_strOfficeDetails;
	protected $m_intRoomNumber;
	protected $m_intCreatedBy;
	protected $m_strCreatedOn;
	protected $m_intUpdatedBy;
	protected $m_strUpdatedOn;
	protected $connection;

	public function  __construct() {
		if( true == isset( $_SERVER['connection'] ) ) {
			$this->connection = $_SERVER['connection'];
		}
	}

	
	/*******************************************************************************************
	******************************** get Functions *********************************************
	*******************************************************************************************/

	public function getId(){
		return $this->m_intId;
	}

	public function getDepartmentId(){
		return $this->m_intDepartmentId;
	}

	public function getSpecilizationId(){
		return $this->m_intSpecilizationId;
	}

	public function getFirstName(){
		return $this->m_strFirstName;
	}

	public function getMiddleName(){
		return $this->m_strMiddleName;
	}

	public function getLastName(){
		return $this->m_strLastName;
	}

	public function getMobileNumber(){
		return $this->m_strMobileNumber;
	}

	public function getPhoneNumber(){
		return $this->m_strPhoneNumber;
	}

	public function getOfficeNumber(){
		return $this->m_strOfficeNumber;
	}

	public function getSpecilizationDetails(){
		return $this->m_strSpecilizationDetails;
	}

	public function getListOfDgress(){
		return $this->m_strListOfDgress;
	}

	public function getIsVisitor(){
		return $this->m_intIsVisitor;
	}

	public function getVisitHospitalName(){
		return $this->m_strVisitHospitalName;
	}

	public function getVisitDayName(){
		return $this->m_strVisitDayName;
	}

	public function getVisitingCharges(){
		return $this->m_intVisitingCharges;
	}

	public function getWardId(){
		return $this->m_intWardId;
	}

	public function getOfficeDetails(){
		return $this->m_strOfficeDetails;
	}

	public function getRoomNumber(){
		return $this->m_intRoomNumber;
	}

	public function getCreatedBy(){
		return $this->m_intCreatedBy;
	}

	public function getCreatedOn(){
		return $this->m_strCreatedOn;
	}

	public function getUpdatedBy(){
		return $this->m_intUpdatedBy;
	}

	public function getUpdatedOn(){
		return $this->m_strUpdatedOn;
	}
	
	/*******************************************************************************************
	********************************* set Functions ********************************************
	*******************************************************************************************/

	public function setId( $Id ){
		$this->m_intId = $Id;
	}

	public function setDepartmentId( $DepartmentId ){
		$this->m_intDepartmentId = $DepartmentId;
	}

	public function setSpecilizationId( $SpecilizationId ){
		$this->m_intSpecilizationId = $SpecilizationId;
	}

	public function setFirstName( $FirstName ){
		$this->m_strFirstName = $FirstName;
	}

	public function setMiddleName( $MiddleName ){
		$this->m_strMiddleName = $MiddleName;
	}

	public function setLastName( $LastName ){
		$this->m_strLastName = $LastName;
	}

	public function setMobileNumber( $MobileNumber ){
		$this->m_strMobileNumber = $MobileNumber;
	}

	public function setPhoneNumber( $PhoneNumber ){
		$this->m_strPhoneNumber = $PhoneNumber;
	}

	public function setOfficeNumber( $OfficeNumber ){
		$this->m_strOfficeNumber = $OfficeNumber;
	}

	public function setSpecilizationDetails( $SpecilizationDetails ){
		$this->m_strSpecilizationDetails = $SpecilizationDetails;
	}

	public function setListOfDgress( $ListOfDgress ){
		$this->m_strListOfDgress = $ListOfDgress;
	}

	public function setIsVisitor( $IsVisitor ){
		$this->m_intIsVisitor = $IsVisitor;
	}

	public function setVisitHospitalName( $VisitHospitalName ){
		$this->m_strVisitHospitalName = $VisitHospitalName;
	}

	public function setVisitDayName( $VisitDayName ){
		$this->m_strVisitDayName = $VisitDayName;
	}

	public function setVisitingCharges( $VisitingCharges ){
		$this->m_intVisitingCharges = $VisitingCharges;
	}

	public function setWardId( $WardId ){
		$this->m_intWardId = $WardId;
	}

	public function setOfficeDetails( $OfficeDetails ){
		$this->m_strOfficeDetails = $OfficeDetails;
	}

	public function setRoomNumber( $RoomNumber ){
		$this->m_intRoomNumber = $RoomNumber;
	}

	public function setCreatedBy( $CreatedBy ){
		$this->m_intCreatedBy = $CreatedBy;
	}

	public function setCreatedOn( $CreatedOn ){
		$this->m_strCreatedOn = $CreatedOn;
	}

	public function setUpdatedBy( $UpdatedBy ){
		$this->m_intUpdatedBy = $UpdatedBy;
	}

	public function setUpdatedOn( $UpdatedOn ){
		$this->m_strUpdatedOn = $UpdatedOn;
	}
	
	/*******************************************************************************************
	********************************* Insert Functions ********************************************
	*******************************************************************************************/

	public function insert(){
		return $this->connection->RunQuery( "Insert into DOCTORS (department_id, specilization_id, first_name, middle_name, last_name, mobile_number, phone_number, office_number, specilization_details, list_of_dgress, is_visitor, visit_hospital_name, visit_day_name, visiting_charges, ward_id, office_details, room_number, created_by, created_on, updated_by, updated_on) values (" . $this->getDepartmentId() . ", " . $this->getSpecilizationId() . ", '" . $this->getFirstName() . "', '" . $this->getMiddleName() . "', '" . $this->getLastName() . "', '" . $this->getMobileNumber() . "', '" . $this->getPhoneNumber() . "', '" . $this->getOfficeNumber() . "', '" . $this->getSpecilizationDetails() . "', '" . $this->getListOfDgress() . "', " . $this->getIsVisitor() . ", '" . $this->getVisitHospitalName() . "', '" . $this->getVisitDayName() . "', " . $this->getVisitingCharges() . ", " . $this->getWardId() . ", '" . $this->getOfficeDetails() . "', " . $this->getRoomNumber() . ", " . $this->getCreatedBy() . ", now() , " . $this->getUpdatedBy() . ", NULL )");
	}
	
	/*******************************************************************************************
	********************************* Update Functions ********************************************
	*******************************************************************************************/

	public function update(){
		return $this->connection->RunQuery( "UPDATE DOCTORS set  department_id= " . $this->getDepartmentId() . ", specilization_id= " . $this->getSpecilizationId() . ", first_name= '" . $this->getFirstName() . "', middle_name= '" . $this->getMiddleName() . "', last_name= '" . $this->getLastName() . "', mobile_number= '" . $this->getMobileNumber() . "', phone_number= '" . $this->getPhoneNumber() . "', office_number= '" . $this->getOfficeNumber() . "', specilization_details= '" . $this->getSpecilizationDetails() . "', list_of_dgress= '" . $this->getListOfDgress() . "', is_visitor= " . $this->getIsVisitor() . ", visit_hospital_name= '" . $this->getVisitHospitalName() . "', visit_day_name= '" . $this->getVisitDayName() . "', visiting_charges= " . $this->getVisitingCharges() . ", ward_id= " . $this->getWardId() . ", office_details= '" . $this->getOfficeDetails() . "', room_number= " . $this->getRoomNumber() . ", created_by= " . $this->getCreatedBy() . ", updated_by= " . $this->getUpdatedBy() . ",updated_on = now()  where id =" . $this->getId() );
	}
	
	/*******************************************************************************************
	********************************* Delete Functions ********************************************
	*******************************************************************************************/

	public function Delete($intId ) {
		$this->connection->RunQuery( "DELETE FROM doctors WHERE id = $intId");
	}

	public function fetchNextId() {
		$result = $this->connection->RunQuery( "SELECT AUTO_INCREMENT as id FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = 'doctors'" );
		if( false == $result ) return NULL;

		while( $row = $result->fetch_array( MYSQLI_ASSOC ) ) {
			$this->id = $row["id"];
		}

		return $this->id;
	}

}